using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Columbus.Tests.Testing
{
    public static class AssertExtensions
    {
        public static void Throws<TExpectedException>(Action action) where TExpectedException : Exception
        {
            var exceptionCaught = false;
            try
            {
                action();
            }
            catch(Exception ex)
            {
                exceptionCaught = true;
                Assert.IsInstanceOfType(ex, typeof(TExpectedException));
            }

            Assert.IsTrue(exceptionCaught);
        }
    }
}